//
//  RHChoiceMultipleSystemCell.m
//  RuiHeApp
//
//  Created by Yan Chen on 2025/1/9.
//

#import "RHChoiceMultipleSystemCell.h"
#import "RHMeSystemModel.h"
#import "RHDeviceModel.h"

@interface RHChoiceMultipleSystemCell()
@property (nonatomic ,strong) QMUILabel *systemNameLab;

@property (nonatomic ,strong) QMUILabel *devNameTitleLab;

@property (nonatomic ,strong) UIImageView *markView;
@end
@implementation RHChoiceMultipleSystemCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}



- (void)setupUI{
    
    
    QMUILabel *devNameTitleLab = [[QMUILabel alloc] init];
    [devNameTitleLab setTextAlignment:NSTextAlignmentLeft];
    [devNameTitleLab setFont:kBOLDSYSTEMFONT(14)];
    [devNameTitleLab setTextColor:FontColor(@"#3F4443")];
    devNameTitleLab.text = [NSString stringWithFormat:@"%@:",@"系统名称".rh_localized];
    devNameTitleLab.numberOfLines = 2;
    devNameTitleLab.adjustsFontSizeToFitWidth = YES;
    devNameTitleLab.minimumScaleFactor = 0.8;
    [self.contentView addSubview:devNameTitleLab];
    self.devNameTitleLab = devNameTitleLab;
    
    _systemNameLab = [[QMUILabel alloc] init];
    [_systemNameLab setTextAlignment:NSTextAlignmentCenter];
    [_systemNameLab setFont:kSYSTEMFONT(14)];
    [_systemNameLab setTextColor:FontColor(@"#3F4443")];
    _systemNameLab.adjustsFontSizeToFitWidth = YES;
    _systemNameLab.minimumScaleFactor = 0.8;
    [self.contentView addSubview:_systemNameLab];
    
    
    

    
    _markView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"choice_normal"]];
    [_markView setBackgroundColor:UIColor.clearColor];
    [self.contentView addSubview:_markView];
    
    
    
    kWeakSelf;
    [devNameTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(22);
        make.right.equalTo(weakSelf.systemNameLab.mas_left).offset(-5);
        make.centerY.mas_offset(0);
       
    }];
    
    [_systemNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_centerX).offset(-15);
        make.right.equalTo(weakSelf.markView.mas_left).offset(-5);
        make.centerY.equalTo(devNameTitleLab);
    }];
    
    [_markView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.right.mas_offset(-22);
        make.centerY.mas_offset(0);
    }];
    
}

-(void)setSystemModel:(RHMeSystemModel *)systemModel
{
    _systemModel = systemModel;
    self.systemNameLab.text = systemModel.systemName;
    _markView.image = [UIImage imageNamed:systemModel.isSelected?@"choice_selected":@"choice_normal"];
    self.devNameTitleLab.text = [NSString stringWithFormat:@"%@:",@"系统名称".rh_localized];
    
}

-(void)setDevModel:(RHDeviceModel *)devModel
{
    _devModel = devModel;
    self.systemNameLab.text = devModel.deviceId;
    _markView.image = [UIImage imageNamed:devModel.isSelected?@"choice_selected":@"choice_normal"];
    self.devNameTitleLab.text = [NSString stringWithFormat:@"%@:",@"设备ID".rh_localized];
}

@end
